# Definition for a binary tree node.
class TreeNode(object):
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution(object):
    def findTarget(self, root, k):
        """
        :type root: TreeNode
        :type k: int
        :rtype: bool
        """
        a = set()

        self.prevtree(root,k,a)

    def prevtree(self,node,k,a):

        if not node:
            return False
        if k-node.val in a:
            return True
        a.add(node.val)

        return self.prevtree(node.left,k,a) or self.prevtree(node.right,k,a)



